/* ====================================== toast  ====================================== */
import React from 'react'
import { Modal } from 'antd'
import { ExclamationCircleOutlined } from '@ant-design/icons'
// ===================================================================== global declare
const { $fn } = window
// ===================================================================== Confirm
const _ = ({ msg, okText, cancelText, onOk, onCancel, type='confirm', closable=false, width }) => {
	const modal = Modal[type]({
		title: '提示',
		icon: <ExclamationCircleOutlined />,
		content: msg || '确认删除？',
		okText: okText || '确认',
		cancelText: cancelText || '取消',
		onOk: onOk,
		centered: false,
		closable: closable,
		className: 'confirm',
		width:width,
		onCancel: close => {
			if($fn.hasObject(close)) return
			onCancel && onCancel()
			close && close()
		}
	})
	window.modal = modal
	return modal
}
export default _